﻿<phone:PhoneApplicationPage 
    x:Class="Omnia.Wallet.Views.PreferenceView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:viewmodel="clr-namespace:Omnia.ViewModels;assembly=Omnia.ViewModels"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    xmlns:Converters="clr-namespace:Omnia.Converters;assembly=Omnia.Converters"
    xmlns:UX="clr-namespace:Omnia.UX;assembly=Omnia.UX"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d" d:DesignHeight="800" d:DesignWidth="480"
    shell:SystemTray.IsVisible="False">

    <phone:PhoneApplicationPage.Resources>
        <Converters:EnumTranslateConverter x:Key="EnumTranslateConverter"/>
        <Converters:CultureNameToNativeNameConverter x:Key="CultureNameToNativeNameConverter"/>
    </phone:PhoneApplicationPage.Resources>
    
    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot">
        <Grid.DataContext>
            <viewmodel:ViewModelBase/>
        </Grid.DataContext>
        <Grid.Background>
            <ImageBrush Stretch="{Binding GlobalSettings.BackgroundImageStretch}" ImageSource="{Binding BackgroundImageSource}"/>
        </Grid.Background>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,12">
            <TextBlock Text="{StaticResource IDS_PAGE_TITLE}" Style="{StaticResource PhoneTextNormalStyle}"/>
            <TextBlock Text="{StaticResource IDS_PAGE_HEADER_PREFERENCE}" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
        </StackPanel>

        <!--ContentPanel - place additional content here-->
        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <Grid.RowDefinitions>
                <RowDefinition/>
                <RowDefinition Height="auto"/>
            </Grid.RowDefinitions>
            <ScrollViewer>
                <StackPanel>
                    <toolkit:ListPicker ItemsSource="{Binding ExistsLanguageFile}" 
                                        SelectedItem="{Binding GlobalSettings.Language,Mode=TwoWay}" 
                                        
                                        Header="{StaticResource IDS_LABEL_PREFERENCE_DISPLAY_LANGUAGE}">
                        <toolkit:ListPicker.ItemTemplate>
                            <DataTemplate>
                                <toolkit:ListPickerItem Content="{Binding Converter={StaticResource CultureNameToNativeNameConverter}}"/>
                            </DataTemplate>
                        </toolkit:ListPicker.ItemTemplate>
                    </toolkit:ListPicker>

                    <UX:UXLinkMenu Content="{StaticResource IDS_LABEL_PREFERENCE_MANAGE_LANGUAGE}" 
                                   Margin="0,6" 
                                   Uri="/Views/LanguageDownloadView.xaml"
                                   HorizontalAlignment="Left"/>

                    <UX:UXLinkMenu Content="{StaticResource IDS_LABEL_PREFERENCE_SETBACKGROUND}"
                                   Margin="0,6"
                                   HorizontalAlignment="Left"
                                   Uri="/Views/GalleriesView.xaml" />

                    <toolkit:ListPicker Header="{StaticResource IDS_LABEL_PREFERENCE_IMAGE_STRETCH}" 
                                        ItemsSource="{Binding GlobalSettings.StretchCollection}" 
                                        SelectedItem="{Binding GlobalSettings.BackgroundImageStretch, Mode=TwoWay}" >
                        <toolkit:ListPicker.ItemTemplate>
                            <DataTemplate>
                                <toolkit:ListPickerItem Content="{Binding Converter={StaticResource EnumTranslateConverter}}" />
                            </DataTemplate>
                        </toolkit:ListPicker.ItemTemplate>
                    </toolkit:ListPicker>
                    
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition/>
                            <ColumnDefinition Width="auto"/>
                        </Grid.ColumnDefinitions>
                        <TextBlock Style="{StaticResource PhoneTextSubtleStyle}" Text="{StaticResource IDS_LABEL_PREFERENCE_CARD_REPAYMENT_NOTIFICATION}"/>
                        <TextBlock Style="{StaticResource PhoneTextNormalStyle}" Grid.Column="1">
                            <Run Text="{Binding Path=GlobalSettings.NotifyDays}"/>
                            <Run Text=" "/>
                            <Run Text="{StaticResource IDS_LABEL_PREFERENCE_CARD_REPAYMENT_NOTIFICATION_UNIT}"/>
                        </TextBlock>
                    </Grid>
                    
                    <Slider Maximum="15" Minimum="1" SmallChange="1" 
                            Value="{Binding Path=GlobalSettings.NotifyDays, Mode=TwoWay, StringFormat=\{0:F0\}}" />
                    <toolkit:ToggleSwitch Header="{StaticResource IDS_LABEL_PREFERENCE_AUTOSAVETOFAV}" 
                                          IsChecked="{Binding GlobalSettings.AutoSavePlace, Mode=TwoWay}"/>
                    
                    <UX:UXLinkMenu Content="{StaticResource IDS_LABEL_PREFERENCE_RESETOPTION}" 
                                   Command="{Binding ResetCommand}" 
                                   Grid.Row="1" HorizontalAlignment="Left"/>
                </StackPanel>
            </ScrollViewer>
        </Grid>
    </Grid>
</phone:PhoneApplicationPage>
